<?php
/* @var $this BlogController */
$this->layout = '//layouts/admin/blog';
$this->pageTitle = '文章';
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/blog.js', CClientScript::POS_END);

?>
<div class="container container-admin">
    <div class='row'>
        <div class="span3">
            <?php $this->beginWidget('AdminLeftNavWidget');$this->endWidget();?>
        </div>
        <div class='span9'>
            <div class='page-header' style='padding-bottom:0px'>
                <h2>
                    <span class='fui-new'></span>
                    文章
                    <small class='label'>
                        <a href='<?php echo Yii::app()->createUrl('admin/blog/create');?>'>
							写文章
						</a>
                    </small>
                </h2>
            </div>
            <div class='page-header'>
            	<form class='' name='' action='' method='get'>
	                <button class='btn btn-primary btn-tab'>全部</button>
	                <button class='btn btn-primary btn-tab'>已经发布</button>
	                <button class='btn btn-primary btn-tab'>未发布</button>
	                <input style='padding: 2px;' type='text' name='keyword' value='<?php echo $keyword;?>'placeholder='输入搜索词'/>
	                <select class='blog-category' name='category'>
	                    <option value=''>所有分类</option>
	                    <?php foreach($category as $key=>$value):?>
	                    <option <?php echo $category_id == $value->id ? 'selected' : '';?> value='<?php echo  $value->id;?>'>
	                    	<?php echo $value->screen_name;?>
	                    </option>
	                    <?php endforeach;?>
	                </select>
	                <input type='submit' class='btn' style='padding: 3px 5px;margin-bottom: 10px;' value='筛选文章' />
                </form>
            </div>
            <div class="table" style="min-height:300px">
                <table class='table table-bordered table-hover'>
                    <thead>
                        <tr>
                            <td>ID</td>
                            <td style='min-width:300px'>标题</td>
                            <td>阅览数</td>
                            <td>创建时间</td>
                            <td>更新时间</td>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach($models as $k=>$v):?>
                        <tr>
                            <td><span class="badge"><?php echo $v->id;?></span></td>
                            <td>
                            	<div>
                            		<?php echo HelperString::sysSubStr($v->title,30,true);?>
                            	</div>
                            	<div class='control'>
                            		<input type="hidden" value="<?php echo $v->id;?>" name="blog-id">
                            		<a href='<?php echo Yii::app()->createUrl('site/view',array('id'=>$v->id));?>' target='_blank' class="btn btn-primary btn-small btn-control">查看</a>
                            		<a href='<?php echo Yii::app()->createUrl('admin/blog/update',array('id'=>$v->id));?>' class="btn btn-primary btn-small btn-control">编辑</a>
                            		<a id="blog-lock" href='<?php echo Yii::app()->createUrl('admin/blog/lock',array('id'=>$v->id));?>' class="btn <?php echo $v->is_lock ? '' : 'btn-primary';?> btn-small btn-control">锁定</a>
                            		<a id="blog-delete" href='<?php echo Yii::app()->createUrl('admin/blog/delete',array('id'=>$v->id));?>' class="btn <?php echo $v->is_delete ? '' : 'btn-primary';?> btn-small btn-control">删除</a>
                            	</div>
                        	</td>
                            <td><?php echo $v->read_sum;?></td>
                            <td><?php echo $v->create_date;?></td>
                            <td><?php echo $v->update_date;?></td>
                        </tr>
                        <?php endforeach;?>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <?php 
                $this->widget('CLinkPager', array(
                    'pages' => $pages,
                    'cssFile'=>'',
                    'firstPageCssClass'=>'hidden',
                    'firstPageLabel'=>'',
                    'internalPageCssClass'=>'',
                    'lastPageCssClass'=>'hidden',
                    'lastPageLabel'=>'',
                    'previousPageCssClass'=>'previous',
                    'prevPageLabel'=>'',
                    'nextPageLabel'=>'',
                    'selectedPageCssClass'=>'active',
                    'hiddenPageCssClass'=>'',
                    'header'=>'',
                    'htmlOptions'=>array(
                        'class'=>''
                        )
                    )); 
                ?>
            </div>
        </div>
    </div>
</div>